package com.yan.shopping.controller;

import com.yan.shopping.domain.User;
import com.yan.shopping.service.Mallservicesimpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class ShoopingController {
    public static final Scanner INPUT = new Scanner(System.in);
    public void index(User user){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        while (true) {
            Date date = new Date();
            String format = sdf.format(date);
            System.out.println("登录成功  你好:" + user.getName() + "\t\t" + format);
            System.out.println("***********************电器商城*********************");
            System.out.println("1.商品购买");
            System.out.println("2.我的购物车");
            System.out.println("3.个人信息");
            System.out.println("4.注销");
            System.out.println("***********************电器商城*********************");
            System.out.println("请输入菜单");
            Integer choice = INPUT.nextInt();
            switch (choice){
                case 1:
                    new Mallservicesimpl().buy();
                    break;
                case 2:
                    new Mallservicesimpl().shoppingCart();
                    break;
                case 3:
                    System.out.println("个人信息\n" +
                            "用户名\t密码\t\t昵称\t年龄\t");
                    System.out.println(user.toString());
                    break;
                case 4:{
                    System.exit(0);
                    break;
                }
            }
        }
    }
}
